<?php
/**
 * $Id: bootstrap.php 1038 2012-02-12 00:31:37Z manu $
 * 
 * This file can not be redistributed to anyone without the permission of Giga Promoters
 * Copyright 2005 - 2008, Giga Promoters
 * 						  608 Aggarwal Cyber Plaza
 *						  Netaji Subhash Place, Delhi - 110034
 *						  www.gigapromoters.com
 * 
 *
 * Bootstraps whole CMS engine. Contains some utility functions and hacks.
 * 
 * @version 			$Rev: 1038 $
 * @lastModifiedBy		$LastChangedBy: manu $
 * @lastChanged			$Date: 2012-02-12 06:01:37 +0530 (Sun, 12 Feb 2012) $
 * @copyright 			Giga Promoters (www.gigapromoters.com)
 * 
 */
define('SHOW_VIEW_HINTS', false);
require_once(APP.'plugins'.DS.'cms'.DS.'vendors'.DS.'utility.php');
require_once(APP.'plugins'.DS.'cms'.DS.'vendors'.DS.'global_functions.php');
require_once(APP.'plugins'.DS.'cms'.DS.'vendors'.DS.'cms_debug.php');

//enable profiler
if(Configure::read('Cms.enableProfiler')===null)
{
	Configure::write('Cms.enableProfiler', false);
}
//also show deepprofiling log
if(Configure::read('Cms.deepProfiling') === null)
{
	Configure::write('Cms.deepProfiling', false);
}

//add profiler info in log file
if(Configure::read('Cms.logProfiler')===null)
{
	Configure::write('Cms.logProfiler', false);
}

Configure::write('juiTheme', 'smoothness');
Configure::write('preferedCurrency', '$');
Configure::write('appCode', 'giga');
Configure::write('defaultDateStyle', 'd F Y');
/**
 * Recaptcha settings
 */
Configure::write('Cms.recaptcha.status', false);
Configure::write('Cms.recaptcha.public_key', '6LeNXQoAAAAAAKGggnVdsvcuuI-UWriD22E1YzaQ');
Configure::write('Cms.recaptcha.private_key', '6LeNXQoAAAAAAGY-V4tdZJvfV4llEFtfLGqWjgpt');

/**
 * DB-Based email templates
 * When enabled, email content will be fetched from DB, not the elements.
 */
Configure::write('Cms.dbEmailTemplates', false);

/**
 * Bitly credentials for short urls
 */
Configure::write('Cms.Bitly.login', 'gigapromoters');
Configure::write('Cms.Bitly.apiKey', 'R_bc385f465fdf45cdd14fe15966ea189f');

// include firephp debugging, feel free to comment if it produces issues
require_once(APP.'plugins'.DS.'cms'.DS.'vendors'.DS.'firephp'.DS.'fb.php');

// initialize zend framework libs
//ini_set('include_path',ini_get('include_path') .';'.APP.'vendors'.DS);

cmsDebug('bootstrapping process started');
$plugins = Utility::getAllPlugins();
/* ***********************************************
dirty hack to add viewpaths of plugins 
need alternative approach for this.
@todo: Remove this code if not needed
************************************************/
$modelPaths = array();
$viewPaths = array();
$controllerPaths = array();
$helperPaths = array();
$componentPaths = array();
$behaviorPaths = array();

array_push($helperPaths, APP.'plugins'.DS.'cms'.DS.'views'.DS.'helpers'.DS);
array_push($behaviorPaths, APP.'plugins'.DS.'cms'.DS.'models'.DS.'behaviors'.DS);
array_push($viewPaths, APP.'plugins'.DS.'cms'.DS.'views'.DS);

foreach($plugins as $plugin)
{
	// optimize view paths
	//array_push($viewPaths, APP.'plugins'.DS.$plugin.DS.'views'.DS);

	// define plugin paths
	$pluginName = strtoupper($plugin);
	define($pluginName."_PATH", APP.'plugins'.DS.$plugin.DS);
	define($pluginName."_MODELS_PATH", APP.'plugins'.DS.$plugin.DS.'models'.DS);
	define($pluginName."_VENDORS_PATH", APP.'plugins'.DS.$plugin.DS.'vendors'.DS);	
	
	if($plugin!='cms')
	{
		if(is_file(APP.DS.'plugins'.DS.$plugin.DS.'bootstrap.php'))
		{
			require_once(APP.DS.'plugins'.DS.$plugin.DS.'bootstrap.php');
		}
	}
}

cmsDebug('bootstrapping process ended');
callHooks('afterBootstrap');

// ----all changes to be done after this line ----

if(Configure::read('cmsConfig.Backend.timezone'))
{
	$timezone= Utility::getTimeZone(Configure::read('cmsConfig.Backend.timezone'));
	date_default_timezone_set($timezone);
}

if(Configure::read('debug') > 0)
{
	if(is_file(APP.'config'.DS.'boostrappers'.DS.'current.php'))
	{
		require_once(APP.'config'.DS.'boostrappers'.DS.'current.php');
	}
}
//path to FFMEPG
Configure::write("cms.Upload.ffmpegPath",null);
?>